<template>
	<view>
		<!--底部高级查询-->
		<view class="cu-bar bg-white tabbar border shop bottom-list" style="border:1px solid #eee">
			<view class="action" @tap.stop="navUrl(searchUrl)">
				<view class="cuIcon-filter" :style="{ color: theme }"></view>
				筛选
				<view class="cu-tag badge" v-show="searchCount != 0">{{ searchCount }}</view>
			</view>
			<view style="margin-left:10rpx" class="action" @tap.stop="navUrl(sortUrl)">
				<view class="cuIcon-order" :style="{ color: theme }"></view>
				排序
				<view class="cu-tag badge" v-show="sortCount != 0">{{ sortCount }}</view>
			</view>
			<view class="submit">总计{{ count }}条</view>
		</view>
	</view>
</template>

<script>
import { mapState } from 'vuex';
export default {
	data() {
		return {
			// status状态   10等待用户点击 20用户点击搜索 30 用户点击排序
			status: 10,
			CustomBar: this.CustomBar,
			flag: true
		};
	},
	computed: {
		...mapState(['theme']),
		searchCount() {
			let count = 0;
			let _this = this;
			// console.log(this.searchModel)
			Object.getOwnPropertyNames(_this.searchModel).forEach(function(key) {
				if (typeof _this.searchModel[key] === 'string') {
					if (_this.searchModel[key] != '' && _this.searchModel[key] != null) {
						count++;
					}
				}
			});
			return count;
		},
		sortCount() {
			let count = 0;
			let _this = this;
			Object.getOwnPropertyNames(_this.sortModel).forEach(function(key) {
				if (typeof _this.sortModel[key] === 'string') {
					if (_this.sortModel[key] != '' && _this.sortModel[key] != null) {
						count++;
					}
				}
			});
			return count;
		}
	},
	props: {
		count: {
			type: Number,
			default: 0
		},
		searchUrl: {
			type: String,
			default: ''
		},
		sortUrl: {
			type: String,
			default: ''
		},
		searchModel: {
			type: Object,
			default() {
				return {};
			}
		},
		sortModel: {
			type: Object,
			default() {
				return {};
			}
		}
	},
	methods: {
		navUrl(url) {
			uni.navigateTo({
				url: url,
				success: res => {},
				fail: () => {},
				complete: () => {}
			});
		}
	}
};
</script>

<style scoped>
.bottom-list {
	position: fixed;
	bottom: 0;
	width: 100%;
}
.search-modal {
	position: absolute;
	bottom: 0;
	max-height: 50vh;
	width: 100%;
}
.search-modal .cu-dialog {
	width: 100%;
}
.order-icon {
	font-size: 60rpx;
}
</style>
